
//% color="#c78a5c" iconWidth=50 iconHeight=40
namespace MEMSgas{

    
    //% block="MEMSgas begin[TEXT] A0[A0] A1[A1] " blockType="command"
    //% TEXT.shadow="string" TEXT.defl="mems1"
    //% A0.shadow="dropdown" A0.options="A0"
    //% A1.shadow="dropdown" A1.options="A1"
    export function MEMSgas_Iint(parameter: any, block: any) {
        let tx=parameter.TEXT.code;  
        let a0=parameter.A0.code; 
        let a1=parameter.A1.code; 
        tx = tx.replace(/"/g,"")
        
        Generator.addImport(`from pinpong.libs.dfrobot_mics import DFRobot_MICS_I2C\n`)

        if (`${a0}`==='0' & `${a1}`==='0'){
            console.log(1)
            
            Generator.addCode(`${tx} = DFRobot_MICS_I2C(0x75)\n`)
        }else if (`${a0}`==='1' && `${a1}`==='0'){
            console.log(2)
            Generator.addCode(`${tx} = DFRobot_MICS_I2C(0x76)\n`)
        }else if (`${a0}`==='0' && `${a1}`==='1'){
            console.log(3)
            Generator.addCode(`${tx} = DFRobot_MICS_I2C(0x77)\n`)
        }else if (`${a0}`==='1' && `${a1}`==='1'){
            console.log(4)
            Generator.addCode(`${tx} = DFRobot_MICS_I2C(0x78)\n`)
        }
        
        
    }
    //% block="MEMSgas_[TEXT]warm_up_time " blockType="command"
    //% TEXT.shadow="string" TEXT.defl="mems1"
    export function MEMSgaswarm_up_time(parameter: any, block: any) {
        let tx=parameter.TEXT.code;   
        tx = tx.replace(/"/g,"")     
        Generator.addCode(`${tx}.warm_up_time(0x03)\n`)
        
    }
    //% block="MEMSgas [TEXT] get_power_mode" blockType="boolean"
    //% TEXT.shadow="string" TEXT.defl="mems1"
    export function MEMSgas_get_power_mode(parameter: any, block: any) {
        let tx=parameter.TEXT.code; 
        tx = tx.replace(/"/g,"")   
        Generator.addCode(`${tx}.get_power_mode() == ${tx}.SLEEP_MODE`)
         
    } 
    //% block="MEMSgas [TEXT] set_mode[MODE] " blockType="command"
    //% TEXT.shadow="string" TEXT.defl="mems1"
    //% MODE.shadow="dropdown" MODE.options="MODE"
    export function MEMSgasset_mode(parameter: any, block: any) {
        let tx=parameter.TEXT.code; 
        let mode=parameter.MODE.code; 
        tx = tx.replace(/"/g,"")          
           
        Generator.addCode(`${tx}.${mode}()`)
        
    }
    //% block="---"
    export function noteSep1() {

    }
    //% block="MEMSgas [TEXT]get_adc_data[DATA]" blockType="reporter"
    //% TEXT.shadow="string" TEXT.defl="mems1"
    //% DATA.shadow="dropdown" DATA.options="DATA"
    
    export function MEMSgasget_adc_data(parameter: any, block: any) {
        let tx=parameter.TEXT.code; 
        let data=parameter.DATA.code; 
        tx = tx.replace(/"/g,"")          
        
        Generator.addCode(`${tx}.get_adc_data(${tx}.${data})`)
    }   
    
    //% block="---"
    export function noteSep2() {

    }
    //% block="MEMSgas [TEXT]get_gas_exist[TYPE]" blockType="boolean"
    //% TEXT.shadow="string" TEXT.defl="mems1"
    //% TYPE.shadow="dropdown" TYPE.options="TYPE"
    export function MEMSgasget_gas_exist(parameter: any, block: any) {
        let tx=parameter.TEXT.code; 
        let type=parameter.TYPE.code; 
        tx = tx.replace(/"/g,"")          
         
        Generator.addCode(`${tx}.get_gas_exist(${tx}.${type}) == ${tx}.ERROR`)
    } 

    //% block="---"
    export function noteSep3() {

    }
    //% block="MEMSgas [TEXT]get_gas_ppm[TYPE]" blockType="reporter"
    //% TEXT.shadow="string" TEXT.defl="mems1"
    //% TYPE.shadow="dropdown" TYPE.options="TYPE"
    export function MEMSgasget_gas_ppm(parameter: any, block: any) {
        let tx=parameter.TEXT.code; 
        let type=parameter.TYPE.code; 
        tx = tx.replace(/"/g,"")   
 
        Generator.addCode(`${tx}.get_gas_ppm(${tx}.${type})`)


    }
   }